namespace cSharpStudents415.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class blog_alumi : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Courses", "Student_StudentId", "dbo.Students");
            DropIndex("dbo.Courses", new[] { "Student_StudentId" });
            CreateTable(
                "dbo.Alumni",
                c => new
                    {
                        AlumniId = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Level = c.Int(nullable: false),
                        GradeAverage = c.Double(nullable: false),
                        EmailAddress = c.String(),
                        Horoscope = c.String(),
                        CourseId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.AlumniId);
            
            CreateTable(
                "dbo.Articles",
                c => new
                    {
                        ArticleId = c.Int(nullable: false, identity: true),
                        Title = c.String(),
                        Body = c.String(),
                        BlogId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ArticleId)
                .ForeignKey("dbo.Blogs", t => t.BlogId, cascadeDelete: true)
                .Index(t => t.BlogId);
            
            CreateTable(
                "dbo.Blogs",
                c => new
                    {
                        BlogId = c.Int(nullable: false, identity: true),
                        BlogType = c.String(),
                    })
                .PrimaryKey(t => t.BlogId);
            
            AddColumn("dbo.Courses", "Alumni_AlumniId", c => c.Int());
            CreateIndex("dbo.Courses", "Alumni_AlumniId");
            AddForeignKey("dbo.Courses", "Alumni_AlumniId", "dbo.Alumni", "AlumniId");
            DropColumn("dbo.Courses", "Student_StudentId");
            DropTable("dbo.Students");
        }
        
        public override void Down()
        {
            CreateTable(
                "dbo.Students",
                c => new
                    {
                        StudentId = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Level = c.Int(nullable: false),
                        GradeAverage = c.Double(nullable: false),
                        EmailAddress = c.String(),
                        Horoscope = c.String(),
                        CourseId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.StudentId);
            
            AddColumn("dbo.Courses", "Student_StudentId", c => c.Int());
            DropForeignKey("dbo.Articles", "BlogId", "dbo.Blogs");
            DropForeignKey("dbo.Courses", "Alumni_AlumniId", "dbo.Alumni");
            DropIndex("dbo.Articles", new[] { "BlogId" });
            DropIndex("dbo.Courses", new[] { "Alumni_AlumniId" });
            DropColumn("dbo.Courses", "Alumni_AlumniId");
            DropTable("dbo.Blogs");
            DropTable("dbo.Articles");
            DropTable("dbo.Alumni");
            CreateIndex("dbo.Courses", "Student_StudentId");
            AddForeignKey("dbo.Courses", "Student_StudentId", "dbo.Students", "StudentId");
        }
    }
}
